<template>
  <div>
    <div>
      <el-container class="box">
        <el-aside width="200px">
            <el-row class="tac">
  
  <el-col :span="24">
    <el-menu
      default-active="/"
      class="el-menu-vertical-demo"

      background-color="#ff6141"
      text-color="#f5f5f5"
      active-text-color="#ffd04b"
      unique-opened
      router>
      
      <el-menu-item index="/">
        <i class="el-icon-location-outline"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <!-- 有目录 -->
      <div index="1" v-for="(item,index) in  user.menus" :key="index">
        <el-submenu :index='item.id+""'  v-if="item.children">
        <template slot="title">
          <i :class="item.icon"></i>
          <span>{{item.title}}</span>
        </template>
        <el-menu-item-group v-for="(i,index) in item.children" :key="index">
          <el-menu-item :index="i.url">{{i.title}}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <!-- 无目录 -->
      <el-menu-item :index="item.url" v-else>{{item.title}}</el-menu-item>
      </div>
    </el-menu>
  </el-col>
</el-row>
        </el-aside>
        <el-container>
          <el-header> 
             <p>会员：{{user.username}}</p>
            <el-button type="primary" plain @click="getout">退出</el-button>
            </el-header>
          <el-main>
              <el-breadcrumb separator="/">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>{{$route.meta.title}}</el-breadcrumb-item>
                </el-breadcrumb>
                <router-view></router-view>
          </el-main>
        </el-container>
      </el-container>
    </div>
  </div>
</template>

<script>
import {mapActions,mapGetters} from 'vuex'
import { successAlert } from "../../util/alert"
export default {
  methods:{
    ...mapActions({
      reqchangeuser:'reqchangeuser'
    }),
    // 点击退出
    getout(){
      this.reqchangeuser()
      successAlert('退出成功')
      this.$router.push('/login')
    }
  },
  computed:{
    ...mapGetters({
      user:'user'
    })
  },
  mounted() {
    console.log(this.user);
  },
};
</script>

<style scoped lang="less">
@import url(../../less/index.less);
.box {
  width: 100vw;
  height: 100vh;
}
.el-header {
  background-color: @color2;
}
.el-aside {
  background-color: @color1;
}
.el-main {
  background-color: #e9eef3;
}
</style>